package com.yidu.ladder.delivery.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.ladder.delivery.domain.BasicJobList;
import com.yidu.ladder.delivery.domain.ChargingInfo;
import com.yidu.ladder.delivery.domain.Pack;
import com.yidu.ladder.delivery.domain.PackInfo;
import com.yidu.ladder.delivery.domain.PackVo;
import com.yidu.ladder.delivery.service.PackService;

/**
 * 包装控制器
 * @author ld
 *
 */
@Controller
@RequestMapping("/delivery/pack")
public class PackController {
	
	@Autowired
	private PackService packService;

	/**
	 * 查询所有基本工作单编号
	 * @return 工作单编号集合
	 */
	@ResponseBody
	@RequestMapping(value = "/jobListNo", method = RequestMethod.GET)
	public List<String> findAllBasicJobListNo(){
		//调用查询所有基本工作单编号
		return packService.findAllBasicJobListNo();
	}
	
	
	/**
	 * 根据工作单编号查询工作单
	 * @return 基本工作单对象
	 */
	@ResponseBody
	@RequestMapping(value = "/basicJobList", method = RequestMethod.GET)
	public BasicJobList findBasicJobList(String jobListNo){
		//调用根据工作单编号查询基本工作单
		return packService.findBasicJobList(jobListNo);
	}
	
	/**
	 * 添加包装单
	 * @return 成功返回true，失败false
	 */
	@ResponseBody
	@RequestMapping(value = "/addPack", method = RequestMethod.POST)
	public boolean addPack(@RequestBody List<Pack> packList){
		//调用添加包装方法
		return packService.addPack(packList);
	}
	
	/**
	 * 查询所有包装单
	 * @param paramMap 查询参数
	 * @return 包装单集合
	 */
	@ResponseBody
	@RequestMapping(value = "/findAllPack", method = RequestMethod.GET)
	public Map<String, Object> findAllPack(@RequestParam Map<String, Object> paramMap){
		//调用查询所有包装
		return packService.findAllPack(paramMap);
	}
	
	/**
	 * 查询所有包装信息
	 * @param paramMap 查询参数
	 * @return 包装信息集合
	 */
	@ResponseBody
	@RequestMapping(value = "/findAllPackInfo", method = RequestMethod.GET)
	public Map<String, Object> findAllPackInfo(){
		//调用查询所有包装信息
		return packService.findAllPackInfo();
	}
	
	/**
	 * 查询所有包装单的工作单号
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/packJobListNo", method = RequestMethod.GET)
	public List<String> findAllPackJobListNo(){
		//调用查询所有包装单的工作单号
		return packService.findAllPackJobListNo();
	}
	
	/**
	 * 查询包装单
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/findPack", method = RequestMethod.GET)
	public Pack findPack(String jobListNo){
		//调用查询包装单
		return packService.findPack(jobListNo);
	}
	
	/**
	 * 查询包装信息（包装费）
	 * @param packaingProject
	 * @param specifications
	 * @return
	 */
	@ResponseBody 
	@RequestMapping(value="/findPackInfo", method = RequestMethod.GET)
	public PackInfo findPackaingProjectAndSize(String packaingProject,String specifications) {
		//调用查询包装信息（包装费）
		return packService.findPackInfoByProjectAndSize(packaingProject, specifications);
	}
	
	/**
	 * 修改包装单表、工作单表、计费信息表的信息
	 * @param pack 包装表
	 * @param basicJobList 工作单表
	 * @param charginInfo 计费信息表
	 * @return 返回是否修改成功
	 */
	@ResponseBody
	@RequestMapping(value = "/updatePackInfo", method = RequestMethod.POST)
	public boolean updatePackInfo(Pack pack, BasicJobList basicJobList, ChargingInfo chargingInfo) {
		//调用修改包装单表、工作单表、计费信息表的信息
		return packService.updatePackInfo(pack, basicJobList, chargingInfo);
	}
	
	/**
	 * 查询所有包装的完整信息
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/findPackWhole", method = RequestMethod.GET)
	public Map<String, Object> findPackWhole(@RequestParam Map<String, Object> paramMap) {
		//调用查询所有包装的完整信息
		return packService.findPackWhole(paramMap);
	}
	
	/**
	 * 打印条码
	 * @param jobListNo
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value= "/findBarCodeInfo", method = RequestMethod.GET)
	public PackVo findBarCodeInfo(String jobListNo) {
		//调用查询条码信息
		return packService.findBarCodeInfo(jobListNo);
	}
	
	/**
	 * 查询所有包装完成的工作单号
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/findAllPackSuccess", method = RequestMethod.GET)
	public List<String> findAllPackSuccess(){
		//查询所有打包完的工作单号
		return packService.findAllPackSuccess();
	}
}
